<template>
	<view class="allme">
		
		<view class="div1">
			<view id="settings" @click="gotosettings()">
				<text class="t-icon t-icon-shezhi seticon" ></text>
			</view>
			<image class="head"  v-bind:src="base64str" @click="gotoselfinfo()"></image>
			<text v-model="username">{{username}}</text>
			 
			<button class="btn"  @click="gotologin()" v-bind:style="display">登陆/注册</button>
		
			
			<!-- <text v-model="tips">{{tips}}</text> -->
		
		</view>
		

		
	</view>
</template>

<script>
	
	export default {
		
		data(){
			return{
				// icon:"",
				username:"",
				base64str:"",
				display:"",
				tips:"",
			}
			
		},
		
		methods:{
			 gotologin(){
			        uni.navigateTo({
			            // url: 'test?id=1&name=uniapp'  c传递参数
			            url:"./login"
			        });
			    },
				removestorage(){
					uni.removeStorageSync("token")
					uni.removeStorageSync("username")
					uni.removeStorageSync("iconpath")
					uni.removeStorageSync("nicheng")
					uni.removeStorageSync("phone")
					this.base64str="../../static/head.png"
					this.username="";
					this.display="block";
					
				},
				gotoselfinfo(){
					
					
					if(uni.getStorageSync("token")==""){
						uni.showToast({
							title:"请先登录",
							icon:'none'
						})
					}
					else{uni.navigateTo({
						url:'./selfinfo'
					});}
					 
				},
				gotosettings(){
					
					
					if(uni.getStorageSync("token")==""){
						uni.showToast({
							title:"请先登录",
							icon:'none'
						})
					}
					else{
						uni.navigateTo({
							url:'./settings'
						});
					}
					
				}
				
				
			},
			onLoad() {
				this.base64str="../../static/head.png"
			
				var token=uni.getStorageSync("token")
				this.tips=token
				if(token!=" "){
					
					uni.showToast({
					title: '不为空',
					icon:'none',
					duration: 2000
					}); 
					this.display="display: none;"
					
				}
				else{
					uni.showToast({
					title: '为空',
					icon:'none',
					duration: 2000
					}); 
				}
				
			},
			onShow() {
				var token=uni.getStorageSync("token")
				if(token!=""){
					uni.showToast({
						title: '不为空',
						icon:'none',
						duration: 2000
						}); 
					this.display="display: none;"
					this.username=uni.getStorageSync("nicheng");
					var tmp=uni.getStorageSync("iconpath");
					this.base64str="data:image/png;base64,"+tmp.replace(/[\r\n]/g,'');
				}
				else{
					uni.showToast({
						title: '为空',
						icon:'none',
						duration: 2000
						}); 
					this.base64str="../../static/head.png"
					this.display="display: block;"
					this.username="";
				}
				
				
				
			},
			
			
	
	
	}
	
</script>

<style scoped>
	
	.allme{
		background-color: #007AFF;
		height: 100%;
		overflow: hidden;
	}
	.div1{
		height: 300px;
		background-color: #FFFFFF;
		border-radius: 20upx;
		margin: 10px;
		
		display: flex;
		flex-direction: column;
		align-items: center;
		
		overflow: hidden;
	}
	.head{
		width: 60px;
		height: 60px;
		margin-top: 20px;
		border-radius: 50%;
		border-color: #000000;
		border-width: 1px;
		border-style: solid;
		padding: 1px;
		
	
		
	}

	.btn{
		margin-top: 30px;
		background-color: transparent;
		
		
		
	}
	.seticon{
		width: 25px;
		height: 25px;
		background-repeat: no-repeat;
	}
	
	#settings{
		margin-left:80%;
		margin-top: 5%; 
		width: 20px;
		height: 20px;
		
	}
	
</style>
